package com.yya.ratelimiter.exception;

import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;

import java.util.HashMap;
import java.util.Map;

/**
 * @Autor: yuanyongan
 * @Description:
 * @Date 2023/1/10 15:16
 */

@RestControllerAdvice
public class GlobalException extends RuntimeException{
    @ExceptionHandler(RateLimitException.class)
    public Map<String, Object> rateLimit(RateLimitException e){
        Map<String, Object> map = new HashMap<>();
        map.put("code", e.getCode());
        map.put("msg", e.getMsg());
        return map;
    }
}
